package cn.xbest.rabbitmq.study.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class Sender {
    @Autowired
    private RabbitTemplate  rabbitTemplate;

    public void send(String message){
        log.info("总台呼叫:"+message);
        rabbitTemplate.convertAndSend("交换机","",message);
    }
    public void dsend1(String msg) {
        log.info("安静,听我说两句:"+msg);
        rabbitTemplate.convertAndSend("我是路由模式的交换机","jsd2211",msg);
    }
    public void dsend2(String msg) {
        log.info("安静,听我说两句:"+msg);
        rabbitTemplate.convertAndSend("我是路由模式的交换机","cgb2211",msg);
    }
    public void tsend1(String msg) {
        log.info("安静,听我说两句:"+msg);
        rabbitTemplate.convertAndSend("我是主题模式的交换机","a.xbest.b",msg);
    }
    public void tsend2(String msg) {
        log.info("安静,听我说两句:"+msg);
        rabbitTemplate.convertAndSend("我是主题模式的交换机","test.jsd",msg);
    }

}
